<%@ taglib uri="/WEB-INF/tld/struts-html.tld"   prefix="html"%>

<%@page import="java.util.Iterator,java.util.Collection, org.tigris.atlas.quizme.bizobj.QuizBO,org.tigris.atlas.quizme.client.utils.Constants"%>
<div class="tab-page">
		<div id="subPages" class="disabled link-row">
			<table class="wide-table">
				<tr>
					<td width="100%" height="10">
							&nbsp;
					</td>
				</tr>
			</table>
		</div>
		
	<table cellpadding="0" cellspacing="0" border="0">
	<tr>
   <td colspan="2">
   <%
   		Collection quizzes = (Collection)request.getSession().getAttribute(Constants.QUIZ_HISTORY_KEY);
  		 Iterator i = quizzes.iterator();
   		
   		java.text.SimpleDateFormat format = new java.text.SimpleDateFormat("mm:ss");
   		java.text.SimpleDateFormat fullFormat = new java.text.SimpleDateFormat("MM/dd/yyyy");
	%>
	
	<P><H2>Past Quiz Scores</H2></P>

	<table border="1px">
	<tr bgcolor="#cc0500">
		<td><B>Date Taken</B></td>
		<td><B>Score</B></td>
		<td><B>Time Used</B></td>
		<td><B>Time Per Question</B></td>
	</tr>
	<% 
		
		while(i.hasNext()){
			QuizBO quiz = (QuizBO)i.next();
			java.util.Date start = quiz.getTimeStarted();
	   		java.util.Date end = quiz.getTimeEnded();
	   		long totalTime = end.getTime() - start.getTime();
	   		java.util.Date totalTimeObject = new java.util.Date(totalTime);
	   		long timePerQuestion = totalTime/quiz.getNumQuestions().intValue();
	   		java.util.Date timePerObject = new java.util.Date(timePerQuestion);
	%>
	<tr>
		<td>
			<%= fullFormat.format(quiz.getTimeEnded())%>
		</td>
		<td>
			<%= quiz.getNumCorrect()%> out of <%= quiz.getNumQuestions()%> 
		</td>
		<td><%= format.format(totalTimeObject) %></td>
		<td><%= format.format(timePerObject) %></td>
	</tr>
	<% } %>
	</table>
<BR>
</td>
</tr>
</table>